Best JavaScript code snippet using storybook-root
get_test.js
Source:get_test.js
1load('steal/rhino/rhino.js')2load('steal/rhino/test.js');3steal('steal','steal/get/post.js','steal/get/base64.js','steal/get',function(rhinoSteal, post, base64){4 var _S = steal.test;5 var G = steal.get;6 7 _S.test("base64", function(t){8 base64.encode("hello world") ;9 });10 11 _S.module("steal/get")12 STEALPRINT = false;13 14 _S.test("pluginList", function(t){15 var url = rhinoSteal.get.url("mxui/util/selectable");16 17 t.equals(url, "https://github.com/jupiterjs/mxui/tree/master/util/selectable/", "Right url")18 });19 20 21 _S.test("dummySteal", function(t){22 var code = readFile('steal/get/test/stealCode1.js');23 var results = rhinoSteal.dummy(code);24 t.equals(results.plugins[0], "foo/bar", "first is right");25 t.equals(results.plugins.length, 4, "has other plugins")26 });27 28// _S.test("installDependency", function(t){29// rhinoSteal.File("jqueryui").removeDir();30// //t.equals( rhinoSteal.get.installDependency("jquery/controller") , false, "exists" );31// t.equals( rhinoSteal.get.installDependency("jqueryui/draggable") , true, "doesn't exist" );32// 33// 34// });35// 36// _S.test("root repo" , function(t){37// 38// rhinoSteal.get('ss/router',{});39// 40// var license = readFile("ss/router/LICENSE");41// 42// t.ok(license, "ss downloaded");43// rhinoSteal.File("ss").removeDir();44// });45// 46// _S.test("deep repo" , function(t){ 47// rhinoSteal.get('srchr',{});48// 49// var srchr = readFile("srchr/srchr.html");50// 51// t.ok(srchr, "srchr downloaded");52// rhinoSteal.File("srchr").removeDir();53// });54 55 56 57 58 59 60 _S.module("steal/get/github")61 // STEALPRINT = false;62 63 _S.test("github.info", function(t){64 var info = G.git.info("https://github.com/secondstory/secondstoryjs-plugins/");65 66 t.equals(info.user, "secondstory", "Right user");67 t.equals(info.repo, "secondstoryjs-plugins", "Right repo");68 t.equals(info.branch, "master", "Right branch");69 t.equals(info.resource, "/", "Right resource");70 });71 72 _S.test("fetch with git, ignore all", function(t){73 74 G.fetch("https://github.com/jupiterjs/funcunit",75 "steal/get/test/",{76 getter : G.git,77 ignore : [/.*[^\/]$/]78 });79 80 });81 82 _S.test("github.raw", function(t){83 // a file84 var raw = G.git.raw("https://github.com/jupiterjs/srchr/tree/master/srchr/disabler/disabler.html");85 t.equals(raw, "https://raw.github.com/jupiterjs/srchr/master/srchr/disabler/disabler.html", "file");86 87 raw = G.git.raw("https://github.com/secondstory/secondstoryjs-plugins/blob/master/jScrollPane/jScrollPane.js");88 t.equals(raw, "https://raw.github.com/secondstory/secondstoryjs-plugins/master/jScrollPane/jScrollPane.js", "file");89 // folders90 raw = G.git.raw("https://github.com/secondstory/secondstoryjs-plugins/tree/master/jScrollPane/")91 t.equals(raw.indexOf("https://api.github.com/repos/secondstory/secondstoryjs-plugins/git/trees/"), 0, "folder");92 93 // root94 raw = G.git.raw("https://github.com/jupiterjs/funcunit")95 t.equals(raw.indexOf("https://api.github.com/repos/jupiterjs/funcunit/git/trees/"), 0, "root");96 97 raw = G.git.raw("https://github.com/jupiterjs/funcunit/tree/v3.2.1")98 t.equals(raw.indexOf("https://api.github.com/repos/jupiterjs/funcunit/git/trees/"), 0, "root with tag");99 100 });101 102 _S.test("github.ls", function(t){103 var raw = G.git.raw("https://github.com/jupiterjs/funcunit"),104 contents = readUrl(raw);105 106 var map = G.git.ls(contents, raw, "https://github.com/jupiterjs/funcunit");107 108 //for(var name in map){109 // print(name+" - "+map[name])110 //}111 112 });113 114 _S.test("fetcher.download", function(t){115 var url = "https://github.com/jupiterjs/funcunit/blob/master/dependencies.json",116 out = "steal/get/test/out.js";117 118 G.download(url,out,{getter: G.git});119 120 var stuff = readFile(out);121 t.ok(stuff, "there is stuff");122 123 new steal.File(out).remove();124 });125 126 127 128 /*_S.test("fetch with basic, ignore all", function(t){129 130 G.fetch("http://jabbify.googlecode.com/svn/trunk/jabbify/apps/",131 "steal/get/test/",{132 getter : G.basic,133 ignore : [/.*[^\/]$/]134 });135 136 });*/137 138 139 _S.test("fetch dependencies", function(t){140 141 var depends = steal.get.dependencies("https://github.com/jupiterjs/funcunit",142 {getter: steal.get.git});143 144 t.equals(depends["funcunit/syn"], "https://github.com/jupiterjs/syn", "dependency");145 146 });147 148 _S.test("steals dependencies", function(t){149 150 var steals = steal.get.steals("https://github.com/jupiterjs/mxui/tree/master/data/grid",151 {getter: steal.get.git});152 t.ok(steals.length, "we got something") 153 // -> ['mxui/layout/table_scroll','mxui/data','jquery/controller/view',..]154 155 for(var i =0; i < steals.length; i++){156 if(steals[i].indexOf('mxui') > -1){157 t.ok(true, "we have mxui")158 }159 }160 161 });162 ...
StoryObjectFactorySpec.ts
Source:StoryObjectFactorySpec.ts
1// Copyright 2018 The Oppia Authors. All Rights Reserved.2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License at6//7// http://www.apache.org/licenses/LICENSE-2.08//9// Unless required by applicable law or agreed to in writing, software10// distributed under the License is distributed on an "AS-IS" BASIS,11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12// See the License for the specific language governing permissions and13// limitations under the License.14/**15 * @fileoverview Tests for StoryObjectFactory.16 */17require('domain/story/StoryObjectFactory.ts');18describe('Story object factory', function() {19 var StoryObjectFactory = null;20 var _sampleStory = null;21 beforeEach(angular.mock.module('oppia'));22 beforeEach(angular.mock.inject(function($injector) {23 StoryObjectFactory = $injector.get('StoryObjectFactory');24 var sampleStoryBackendDict = {25 id: 'sample_story_id',26 title: 'Story title',27 description: 'Story description',28 notes: 'Notes',29 version: 1,30 corresponding_topic_id: 'topic_id',31 story_contents: {32 initial_node_id: 'node_1',33 nodes: [{34 id: 'node_1',35 title: 'Title 1',36 prerequisite_skill_ids: [],37 acquired_skill_ids: [],38 destination_node_ids: [],39 outline: 'Outline',40 exploration_id: null,41 outline_is_finalized: false42 }],43 next_node_id: 'node_3'44 },45 language_code: 'en'46 };47 _sampleStory = StoryObjectFactory.createFromBackendDict(48 sampleStoryBackendDict);49 }));50 it('should be able to create an interstitial story object', function() {51 var story = StoryObjectFactory.createInterstitialStory();52 expect(story.getId()).toEqual(null);53 expect(story.getTitle()).toEqual('Story title loading');54 expect(story.getDescription()).toEqual('Story description loading');55 expect(story.getLanguageCode()).toBe('en');56 expect(story.getStoryContents()).toEqual(null);57 expect(story.getNotes()).toEqual('Story notes loading');58 expect(story.getCorrespondingTopicId()).toEqual(null);59 });60 it('should correctly validate a valid story', function() {61 expect(_sampleStory.validate()).toEqual([]);62 });63 it('should correctly validate a story', function() {64 _sampleStory.setTitle('');65 expect(_sampleStory.validate()).toEqual([66 'Story title should not be empty'67 ]);68 });69 it('should be able to copy from another story', function() {70 var secondStory = StoryObjectFactory.createFromBackendDict({71 id: 'sample_story_id_2s',72 title: 'Story title 2',73 description: 'Story description 2',74 notes: 'Notes 2',75 version: 1,76 corresponding_topic_id: 'topic_id_2',77 story_contents: {78 initial_node_id: 'node_2',79 nodes: [{80 id: 'node_2',81 title: 'Title 2',82 prerequisite_skill_ids: [],83 acquired_skill_ids: [],84 destination_node_ids: [],85 outline: 'Outline',86 exploration_id: null,87 outline_is_finalized: false88 }],89 next_node_id: 'node_3'90 },91 language_code: 'en'92 });93 expect(_sampleStory).not.toBe(secondStory);94 expect(_sampleStory).not.toEqual(secondStory);95 _sampleStory.copyFromStory(secondStory);96 expect(_sampleStory).not.toBe(secondStory);97 expect(_sampleStory).toEqual(secondStory);98 });...
StoryObjectFactorySpec.js
Source:StoryObjectFactorySpec.js
1// Copyright 2018 The Oppia Authors. All Rights Reserved.2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License at6//7// http://www.apache.org/licenses/LICENSE-2.08//9// Unless required by applicable law or agreed to in writing, software10// distributed under the License is distributed on an "AS-IS" BASIS,11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12// See the License for the specific language governing permissions and13// limitations under the License.14/**15 * @fileoverview Tests for StoryObjectFactory.16 */17describe('Story object factory', function() {18 var StoryObjectFactory = null;19 var _sampleStory = null;20 beforeEach(module('oppia'));21 beforeEach(inject(function($injector) {22 StoryObjectFactory = $injector.get('StoryObjectFactory');23 var sampleStoryBackendDict = {24 id: 'sample_story_id',25 title: 'Story title',26 description: 'Story description',27 notes: 'Notes',28 version: 1,29 story_contents: {30 initial_node_id: 'node_1',31 nodes: [{32 id: 'node_1',33 title: 'Title 1',34 prerequisite_skill_ids: [],35 acquired_skill_ids: [],36 destination_node_ids: [],37 outline: 'Outline',38 exploration_id: null,39 outline_is_finalized: false40 }],41 next_node_id: 'node_3'42 },43 language_code: 'en'44 };45 _sampleStory = StoryObjectFactory.createFromBackendDict(46 sampleStoryBackendDict);47 }));48 it('should be able to create an interstitial story object', function() {49 var story = StoryObjectFactory.createInterstitialStory();50 expect(story.getId()).toEqual(null);51 expect(story.getTitle()).toEqual('Story title loading');52 expect(story.getDescription()).toEqual('Story description loading');53 expect(story.getLanguageCode()).toBe('en');54 expect(story.getStoryContents()).toEqual(null);55 expect(story.getNotes()).toEqual('Story notes loading');56 });57 it('should correctly validate a valid story', function() {58 expect(_sampleStory.validate()).toEqual([]);59 });60 it('should correctly validate a story', function() {61 _sampleStory.setTitle('');62 expect(_sampleStory.validate()).toEqual([63 'Story title should not be empty'64 ]);65 });66 it('should be able to copy from another story', function() {67 var secondStory = StoryObjectFactory.createFromBackendDict({68 id: 'sample_story_id_2s',69 title: 'Story title 2',70 description: 'Story description 2',71 notes: 'Notes 2',72 version: 1,73 story_contents: {74 initial_node_id: 'node_2',75 nodes: [{76 id: 'node_2',77 title: 'Title 2',78 prerequisite_skill_ids: [],79 acquired_skill_ids: [],80 destination_node_ids: [],81 outline: 'Outline',82 exploration_id: null,83 outline_is_finalized: false84 }],85 next_node_id: 'node_3'86 },87 language_code: 'en'88 });89 expect(_sampleStory).not.toBe(secondStory);90 expect(_sampleStory).not.toEqual(secondStory);91 _sampleStory.copyFromStory(secondStory);92 expect(_sampleStory).not.toBe(secondStory);93 expect(_sampleStory).toEqual(secondStory);94 });...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!