@SuppressWarnings("unchecked") private void makeTargetFindable() { given( resourceFinder.loadResource( (ResourceIdentifier<ScriptResource, Void>) target.identifier())) .willReturn(target); }
@Before public void before() { given(target.base()).willReturn(AppBase); given(target.name()).willReturn(targetName); fakeResource(target); count = 0; dependencies = new MockAbstractScriptEnvironmentDependencies( JasmineScriptEnvironment.class, specName, makeResourceLoaded(target)); given(dependencies.mockRhinoContextProvider().context.newObject(global)).willReturn(global); given(dependencies.mockRhinoContextProvider().context.newChainedScope(global)) .willReturn(global); given(jasmine.script()).willReturn(jasmineScript); given(jasmineBoot.script()).willReturn(jasmineBootScript); fakeResource(jasmine); given(resourceFinder.loadResource(ScriptResource.class, Assets, "jasmine.js")) .willReturn(jasmine); fakeResource(jasmineBoot); given(resourceFinder.loadResource(ScriptResource.class, Assets, "jasmine-boot.js")) .willReturn(jasmineBoot); fakeResource(jasmineRun); given(resourceFinder.loadResource(ScriptResource.class, Assets, "jasmine-run.js")) .willReturn(jasmineRun); given(resourceFinder.loadResource(ScriptResource.class, AppBase, targetName)) .willReturn(target); given(spec.base()).willReturn(AppBase); given(spec.name()).willReturn(specName); }
@Test public void testFound() { makeTargetFindable(); fakeResource(spec); given(resourceFinder.loadResource(ScriptResource.class, AppBase, specName)).willReturn(spec); given(pathResolver.specLocationFor(AppBase)).willReturn(AppBase); JasmineScriptEnvironment jse = new JasmineScriptEnvironment( dependencies, global, resourceFinder, pathResolver, makeResourceLoaded(target)); assertThat(jse.name(), is(specName)); assertThat(jse.script(), is(jasmineBootScript)); verifyDependentSetup(jasmine, jse); verifyDependentSetup(jasmineBoot, jse); verifyDependentSetup(jasmineRun, jse); verifyDependentSetup(target, jse); verifyDependentSetup(spec, jse); // make sure we ran our setup (at least the part that matters internally) verify(dependencies.mockRhinoContextProvider().context).executeScript(jasmineScript, global); // TODO VERIFY THE SCOPE! // need some test tools for this // and need to tweak down the scope anyway. it's not right, yet. // inject needs to be renamed // require needs to be renamed // verify the sha is build from all our script buddies. kind of goofy but correct // this is sort of future-prep but this might become a target for socket connections at // some point, to deliver test run results to the browser. maybe assertThat(jse.sha1(), is("4a117d7e27db77e337750a4e380ef4587be12f40")); }