@Test public void snippets_are_generated_for_correct_locale() throws Exception { Backend backend = new TestBackend(); UndefinedStepsTracker tracker = new UndefinedStepsTracker(); tracker.addUndefinedStep(new Step(null, "Если ", "Б", 1, null, null), new I18n("ru")); assertEquals("[Если ^Б$]", tracker.getSnippets(asList(backend)).toString()); }
@Test public void star_keyword_becomes_given_when_no_previous_step() { Backend backend = new TestBackend(); UndefinedStepsTracker tracker = new UndefinedStepsTracker(); tracker.addUndefinedStep(new Step(null, "* ", "A", 1, null, null), ENGLISH); assertEquals("[Given ^A$]", tracker.getSnippets(asList(backend)).toString()); }
@Test public void converts_and_to_previous_step_keyword() { Backend backend = new TestBackend(); UndefinedStepsTracker tracker = new UndefinedStepsTracker(); tracker.storeStepKeyword(new Step(null, "When ", "A", 1, null, null), ENGLISH); tracker.storeStepKeyword(new Step(null, "And ", "B", 1, null, null), ENGLISH); tracker.addUndefinedStep(new Step(null, "But ", "C", 1, null, null), ENGLISH); assertEquals("[When ^C$]", tracker.getSnippets(asList(backend)).toString()); }
@Test public void doesnt_try_to_use_star_keyword() { Backend backend = new TestBackend(); UndefinedStepsTracker tracker = new UndefinedStepsTracker(); tracker.storeStepKeyword(new Step(null, "When ", "A", 1, null, null), ENGLISH); tracker.storeStepKeyword(new Step(null, "And ", "B", 1, null, null), ENGLISH); tracker.addUndefinedStep(new Step(null, "* ", "C", 1, null, null), ENGLISH); assertEquals("[When ^C$]", tracker.getSnippets(asList(backend)).toString()); }
@Test public void removes_duplicates() { Backend backend = new TestBackend(); UndefinedStepsTracker tracker = new UndefinedStepsTracker(); tracker.storeStepKeyword(new Step(null, "Given ", "A", 1, null, null), ENGLISH); tracker.addUndefinedStep(new Step(null, "Given ", "B", 1, null, null), ENGLISH); tracker.addUndefinedStep(new Step(null, "Given ", "B", 1, null, null), ENGLISH); assertEquals("[Given ^B$]", tracker.getSnippets(asList(backend)).toString()); }