/ Published in: Groovy
Expand |
Embed | Plain Text
package com.cadrlife.mywebapp; import groovy.util.GroovyScriptEngine; import org.apache.commons.lang.RandomStringUtils; import org.junit.Before; import org.junit.Test; import com.google.common.collect.Lists; import com.google.common.io.Files; import com.google.common.io.Resources; import org.mozilla.javascript.Context; import org.mozilla.javascript.ContextFactory; import org.mozilla.javascript.ScriptableObject; private ScriptableObject scope; @Before cx = ContextFactory.getGlobal().enterContext(); cx.setOptimizationLevel(-1); scope = cx.initStandardObjects(); // Assumes we have env.rhino.js as a resource on the classpath. // This will load the home page DOM. run("window.location='http://localhost:5000'"); // Whatever script JS includes the home page has. "/js/jquery-ui-1.8.2.custom.min.js", "/js/app.js"]; } // Whatever happens on document ready. run('appInit()'); } @Test run('$(".nav .homeLink").click()'); assertJsEquals('Request Sets', h1Text); run('$(".nav .dashboardLink").click()'); assertJsEquals('Dashboard', h1Text); run('$(".nav .homeLink").click()'); assertJsEquals('Sacrifice Pig', h1Text); } assertEquals(a,run(b)); } } } }
You need to login to post a comment.
