Best JavaScript code snippet using storybook-root
StoryUpdateServiceSpec.ts
Source:StoryUpdateServiceSpec.ts  
...64  }));65  it('should add/remove a prerequisite skill id to/from a node in the story',66    function() {67      expect(68        _sampleStory.getStoryContents().getNodes()[0].getPrerequisiteSkillIds()69      ).toEqual(['skill_1']);70      StoryUpdateService.addPrerequisiteSkillIdToNode(71        _sampleStory, 'node_1', 'skill_3');72      expect(73        _sampleStory.getStoryContents().getNodes()[0].getPrerequisiteSkillIds()74      ).toEqual(['skill_1', 'skill_3']);75      UndoRedoService.undoChange(_sampleStory);76      expect(77        _sampleStory.getStoryContents().getNodes()[0].getPrerequisiteSkillIds()78      ).toEqual(['skill_1']);79    }80  );81  it('should create a proper backend change dict for adding a prerequisite ' +82    'skill id to a node',83  function() {84    StoryUpdateService.addPrerequisiteSkillIdToNode(85      _sampleStory, 'node_1', 'skill_3');86    expect(UndoRedoService.getCommittableChangeList()).toEqual([{87      cmd: 'update_story_node_property',88      property_name: 'prerequisite_skill_ids',89      new_value: ['skill_1', 'skill_3'],90      old_value: ['skill_1'],91      node_id: 'node_1'92    }]);93  });94  it('should add/remove an acquired skill id to/from a node in the story',95    function() {96      expect(97        _sampleStory.getStoryContents().getNodes()[0].getAcquiredSkillIds()98      ).toEqual(['skill_2']);99      StoryUpdateService.addAcquiredSkillIdToNode(100        _sampleStory, 'node_1', 'skill_4');101      expect(102        _sampleStory.getStoryContents().getNodes()[0].getAcquiredSkillIds()103      ).toEqual(['skill_2', 'skill_4']);104      UndoRedoService.undoChange(_sampleStory);105      expect(106        _sampleStory.getStoryContents().getNodes()[0].getAcquiredSkillIds()107      ).toEqual(['skill_2']);108    }109  );110  it('should create a proper backend change dict for adding an acquired ' +111    'skill id to a node',112  function() {113    StoryUpdateService.addAcquiredSkillIdToNode(114      _sampleStory, 'node_1', 'skill_4');115    expect(UndoRedoService.getCommittableChangeList()).toEqual([{116      cmd: 'update_story_node_property',117      property_name: 'acquired_skill_ids',118      new_value: ['skill_2', 'skill_4'],119      old_value: ['skill_2'],120      node_id: 'node_1'121    }]);122  });123  it('should add/remove a destination node id to/from a node in the story',124    function() {125      expect(126        _sampleStory.getStoryContents().getNodes()[0].getDestinationNodeIds()127      ).toEqual([]);128      StoryUpdateService.addDestinationNodeIdToNode(129        _sampleStory, 'node_1', 'node_2');130      // Adding an invalid destination node id should throw an error.131      expect(function() {132        StoryUpdateService.addDestinationNodeIdToNode(133          _sampleStory, 'node_1', 'node_5');134      }).toThrow();135      expect(136        _sampleStory.getStoryContents().getNodes()[0].getDestinationNodeIds()137      ).toEqual(['node_2']);138      UndoRedoService.undoChange(_sampleStory);139      expect(140        _sampleStory.getStoryContents().getNodes()[0].getDestinationNodeIds()141      ).toEqual([]);142    }143  );144  it('should create a proper backend change dict for adding a destination ' +145    'node id to a node',146  function() {147    StoryUpdateService.addDestinationNodeIdToNode(148      _sampleStory, 'node_1', 'node_2');149    expect(UndoRedoService.getCommittableChangeList()).toEqual([{150      cmd: 'update_story_node_property',151      property_name: 'destination_node_ids',152      new_value: ['node_2'],153      old_value: [],154      node_id: 'node_1'155    }]);156  });157  it('should remove/add a prerequisite skill id from/to a node in the story',158    function() {159      expect(160        _sampleStory.getStoryContents().getNodes()[0].getPrerequisiteSkillIds()161      ).toEqual(['skill_1']);162      StoryUpdateService.removePrerequisiteSkillIdFromNode(163        _sampleStory, 'node_1', 'skill_1');164      expect(165        _sampleStory.getStoryContents().getNodes()[0].getPrerequisiteSkillIds()166      ).toEqual([]);167      UndoRedoService.undoChange(_sampleStory);168      expect(169        _sampleStory.getStoryContents().getNodes()[0].getPrerequisiteSkillIds()170      ).toEqual(['skill_1']);171    }172  );173  it('should create a proper backend change dict for removing a prerequisite ' +174    'skill id from a node',175  function() {176    StoryUpdateService.removePrerequisiteSkillIdFromNode(177      _sampleStory, 'node_1', 'skill_1');178    expect(UndoRedoService.getCommittableChangeList()).toEqual([{179      cmd: 'update_story_node_property',180      property_name: 'prerequisite_skill_ids',181      new_value: [],182      old_value: ['skill_1'],183      node_id: 'node_1'184    }]);185  });186  it('should remove/add an acquired skill id from/to a node in the story',187    function() {188      expect(189        _sampleStory.getStoryContents().getNodes()[0].getAcquiredSkillIds()190      ).toEqual(['skill_2']);191      StoryUpdateService.removeAcquiredSkillIdFromNode(192        _sampleStory, 'node_1', 'skill_2');193      expect(194        _sampleStory.getStoryContents().getNodes()[0].getAcquiredSkillIds()195      ).toEqual([]);196      UndoRedoService.undoChange(_sampleStory);197      expect(198        _sampleStory.getStoryContents().getNodes()[0].getAcquiredSkillIds()199      ).toEqual(['skill_2']);200    }201  );202  it('should create a proper backend change dict for removing an acquired ' +203    'skill id from a node',204  function() {205    StoryUpdateService.removeAcquiredSkillIdFromNode(206      _sampleStory, 'node_1', 'skill_2');207    expect(UndoRedoService.getCommittableChangeList()).toEqual([{208      cmd: 'update_story_node_property',209      property_name: 'acquired_skill_ids',210      new_value: [],211      old_value: ['skill_2'],212      node_id: 'node_1'213    }]);214  });215  it('should remove/add a destination node id from/to a node in the story',216    function() {217      expect(218        _sampleStory.getStoryContents().getNodes()[1].getDestinationNodeIds()219      ).toEqual(['node_1']);220      StoryUpdateService.removeDestinationNodeIdFromNode(221        _sampleStory, 'node_2', 'node_1');222      expect(223        _sampleStory.getStoryContents().getNodes()[1].getDestinationNodeIds()224      ).toEqual([]);225      UndoRedoService.undoChange(_sampleStory);226      expect(227        _sampleStory.getStoryContents().getNodes()[1].getDestinationNodeIds()228      ).toEqual(['node_1']);229    }230  );231  it('should create a proper backend change dict for removing a destination ' +232    'node id from a node',233  function() {234    StoryUpdateService.removeDestinationNodeIdFromNode(235      _sampleStory, 'node_2', 'node_1');236    expect(UndoRedoService.getCommittableChangeList()).toEqual([{237      cmd: 'update_story_node_property',238      property_name: 'destination_node_ids',239      new_value: [],240      old_value: ['node_1'],241      node_id: 'node_2'242    }]);243  });244  it('should add/remove a story node', function() {245    expect(_sampleStory.getStoryContents().getNodes().length).toEqual(2);246    StoryUpdateService.addStoryNode(_sampleStory, 'Title 2');247    expect(_sampleStory.getStoryContents().getNodes().length).toEqual(3);248    expect(_sampleStory.getStoryContents().getNextNodeId()).toEqual('node_4');249    expect(250      _sampleStory.getStoryContents().getNodes()[2].getId()).toEqual('node_3');251    expect(252      _sampleStory.getStoryContents().getNodes()[2].getTitle()).toEqual(253      'Title 2');254    UndoRedoService.undoChange(_sampleStory);255    expect(_sampleStory.getStoryContents().getNodes().length).toEqual(2);256  });257  it('should create a proper backend change dict for adding a story node',258    function() {259      StoryUpdateService.addStoryNode(_sampleStory, 'Title 2');260      expect(UndoRedoService.getCommittableChangeList()).toEqual([{261        cmd: 'add_story_node',262        node_id: 'node_3',263        title: 'Title 2'264      }]);265    }266  );267  it('should remove/add a story node', function() {268    expect(function() {269      StoryUpdateService.deleteStoryNode(_sampleStory, 'node_2');270    }).toThrow();271    expect(_sampleStory.getStoryContents().getNodes().length).toEqual(2);272    expect(273      _sampleStory.getStoryContents().getNodes()[1].getDestinationNodeIds()274    ).toEqual(['node_1']);275    StoryUpdateService.deleteStoryNode(_sampleStory, 'node_1');276    // Initial node should not be deleted.277    StoryUpdateService.deleteStoryNode(_sampleStory, 'node_2');278    expect(_sampleStory.getStoryContents().getInitialNodeId()).toEqual(null);279    expect(_sampleStory.getStoryContents().getNodes().length).toEqual(0);280    expect(function() {281      UndoRedoService.undoChange(_sampleStory);282    }).toThrow();283  });284  it('should create a proper backend change dict for removing a story node',285    function() {286      StoryUpdateService.deleteStoryNode(_sampleStory, 'node_1');287      expect(UndoRedoService.getCommittableChangeList()).toEqual([{288        cmd: 'delete_story_node',289        node_id: 'node_1'290      }]);291    }292  );293  it('should finalize a story node outline', function() {294    expect(295      _sampleStory.getStoryContents().getNodes()[0].getOutlineStatus()296    ).toBe(false);297    StoryUpdateService.finalizeStoryNodeOutline(_sampleStory, 'node_1');298    expect(299      _sampleStory.getStoryContents().getNodes()[0].getOutlineStatus()300    ).toBe(true);301    UndoRedoService.undoChange(_sampleStory);302    expect(303      _sampleStory.getStoryContents().getNodes()[0].getOutlineStatus()304    ).toBe(false);305  });306  it('should create a proper backend change dict for finalizing a node outline',307    function() {308      StoryUpdateService.finalizeStoryNodeOutline(_sampleStory, 'node_1');309      expect(UndoRedoService.getCommittableChangeList()).toEqual([{310        cmd: 'update_story_node_outline_status',311        new_value: true,312        old_value: false,313        node_id: 'node_1'314      }]);315    }316  );317  it('should unfinalize a story node outline', function() {318    expect(319      _sampleStory.getStoryContents().getNodes()[1].getOutlineStatus()320    ).toBe(true);321    StoryUpdateService.unfinalizeStoryNodeOutline(_sampleStory, 'node_2');322    expect(323      _sampleStory.getStoryContents().getNodes()[1].getOutlineStatus()324    ).toBe(false);325    UndoRedoService.undoChange(_sampleStory);326    expect(327      _sampleStory.getStoryContents().getNodes()[1].getOutlineStatus()328    ).toBe(true);329  });330  it('should create a proper backend change dict for unfinalizing a node ' +331    'outline', function() {332    StoryUpdateService.unfinalizeStoryNodeOutline(_sampleStory, 'node_2');333    expect(UndoRedoService.getCommittableChangeList()).toEqual([{334      cmd: 'update_story_node_outline_status',335      new_value: false,336      old_value: true,337      node_id: 'node_2'338    }]);339  });340  it('should set a story node outline', function() {341    expect(342      _sampleStory.getStoryContents().getNodes()[0].getOutline()343    ).toBe('Outline');344    StoryUpdateService.setStoryNodeOutline(345      _sampleStory, 'node_1', 'new outline');346    expect(347      _sampleStory.getStoryContents().getNodes()[0].getOutline()348    ).toBe('new outline');349    UndoRedoService.undoChange(_sampleStory);350    expect(351      _sampleStory.getStoryContents().getNodes()[0].getOutline()352    ).toBe('Outline');353  });354  it('should create a proper backend change dict for setting a node outline',355    function() {356      StoryUpdateService.setStoryNodeOutline(357        _sampleStory, 'node_1', 'new outline');358      expect(UndoRedoService.getCommittableChangeList()).toEqual([{359        cmd: 'update_story_node_property',360        property_name: 'outline',361        new_value: 'new outline',362        old_value: 'Outline',363        node_id: 'node_1'364      }]);365    }366  );367  it('should set a story node title', function() {368    expect(369      _sampleStory.getStoryContents().getNodes()[0].getTitle()370    ).toBe('Title 1');371    StoryUpdateService.setStoryNodeTitle(372      _sampleStory, 'node_1', 'new title');373    expect(374      _sampleStory.getStoryContents().getNodes()[0].getTitle()375    ).toBe('new title');376    UndoRedoService.undoChange(_sampleStory);377    expect(378      _sampleStory.getStoryContents().getNodes()[0].getTitle()379    ).toBe('Title 1');380  });381  it('should create a proper backend change dict for setting a node title',382    function() {383      StoryUpdateService.setStoryNodeTitle(384        _sampleStory, 'node_1', 'new title');385      expect(UndoRedoService.getCommittableChangeList()).toEqual([{386        cmd: 'update_story_node_property',387        property_name: 'title',388        new_value: 'new title',389        old_value: 'Title 1',390        node_id: 'node_1'391      }]);392    }393  );394  it('should set the exploration id of a story node', function() {395    expect(396      _sampleStory.getStoryContents().getNodes()[0].getExplorationId()397    ).toBe(null);398    StoryUpdateService.setStoryNodeExplorationId(399      _sampleStory, 'node_1', 'exp_2');400    expect(401      _sampleStory.getStoryContents().getNodes()[0].getExplorationId()402    ).toBe('exp_2');403    // Adding an already existing exploration in the story should throw an404    // error.405    expect(function() {406      StoryUpdateService.setStoryNodeExplorationId(407        _sampleStory, 'node_1', 'exp_1');408    }).toThrow();409    UndoRedoService.undoChange(_sampleStory);410    expect(411      _sampleStory.getStoryContents().getNodes()[0].getExplorationId()412    ).toBe(null);413  });414  it('should create a proper backend change dict for setting the exploration ' +415    'id of a node', function() {416    StoryUpdateService.setStoryNodeExplorationId(417      _sampleStory, 'node_1', 'exp_2');418    expect(UndoRedoService.getCommittableChangeList()).toEqual([{419      cmd: 'update_story_node_property',420      property_name: 'exploration_id',421      new_value: 'exp_2',422      old_value: null,423      node_id: 'node_1'424    }]);425  });426  it('should set/unset the initial node of the story', function() {427    expect(428      _sampleStory.getStoryContents().getInitialNodeId()).toEqual('node_2');429    StoryUpdateService.setInitialNodeId(_sampleStory, 'node_1');430    expect(431      _sampleStory.getStoryContents().getInitialNodeId()).toEqual('node_1');432    UndoRedoService.undoChange(_sampleStory);433    expect(434      _sampleStory.getStoryContents().getInitialNodeId()).toEqual('node_2');435  });436  it('should create a proper backend change dict for setting initial node',437    function() {438      StoryUpdateService.setInitialNodeId(_sampleStory, 'node_1');439      expect(UndoRedoService.getCommittableChangeList()).toEqual([{440        cmd: 'update_story_contents_property',441        property_name: 'initial_node_id',442        new_value: 'node_1',443        old_value: 'node_2'444      }]);445    }446  );447  it('should set/unset changes to a story\'s title', function() {448    expect(_sampleStory.getTitle()).toEqual('Story title');...StoryUpdateServiceSpec.js
Source:StoryUpdateServiceSpec.js  
...61  }));62  it('should add/remove a prerequisite skill id to/from a node in the story',63    function() {64      expect(65        _sampleStory.getStoryContents().getNodes()[0].getPrerequisiteSkillIds()66      ).toEqual(['skill_1']);67      StoryUpdateService.addPrerequisiteSkillIdToNode(68        _sampleStory, 'node_1', 'skill_3');69      expect(70        _sampleStory.getStoryContents().getNodes()[0].getPrerequisiteSkillIds()71      ).toEqual(['skill_1', 'skill_3']);72      UndoRedoService.undoChange(_sampleStory);73      expect(74        _sampleStory.getStoryContents().getNodes()[0].getPrerequisiteSkillIds()75      ).toEqual(['skill_1']);76    }77  );78  it('should create a proper backend change dict for adding a prerequisite ' +79    'skill id to a node',80  function() {81    StoryUpdateService.addPrerequisiteSkillIdToNode(82      _sampleStory, 'node_1', 'skill_3');83    expect(UndoRedoService.getCommittableChangeList()).toEqual([{84      cmd: 'update_story_node_property',85      property_name: 'prerequisite_skill_ids',86      new_value: ['skill_1', 'skill_3'],87      old_value: ['skill_1'],88      node_id: 'node_1'89    }]);90  });91  it('should add/remove an acquired skill id to/from a node in the story',92    function() {93      expect(94        _sampleStory.getStoryContents().getNodes()[0].getAcquiredSkillIds()95      ).toEqual(['skill_2']);96      StoryUpdateService.addAcquiredSkillIdToNode(97        _sampleStory, 'node_1', 'skill_4');98      expect(99        _sampleStory.getStoryContents().getNodes()[0].getAcquiredSkillIds()100      ).toEqual(['skill_2', 'skill_4']);101      UndoRedoService.undoChange(_sampleStory);102      expect(103        _sampleStory.getStoryContents().getNodes()[0].getAcquiredSkillIds()104      ).toEqual(['skill_2']);105    }106  );107  it('should create a proper backend change dict for adding an acquired ' +108    'skill id to a node',109  function() {110    StoryUpdateService.addAcquiredSkillIdToNode(111      _sampleStory, 'node_1', 'skill_4');112    expect(UndoRedoService.getCommittableChangeList()).toEqual([{113      cmd: 'update_story_node_property',114      property_name: 'acquired_skill_ids',115      new_value: ['skill_2', 'skill_4'],116      old_value: ['skill_2'],117      node_id: 'node_1'118    }]);119  });120  it('should add/remove a destination node id to/from a node in the story',121    function() {122      expect(123        _sampleStory.getStoryContents().getNodes()[0].getDestinationNodeIds()124      ).toEqual([]);125      StoryUpdateService.addDestinationNodeIdToNode(126        _sampleStory, 'node_1', 'node_2');127      // Adding an invalid destination node id should throw an error.128      expect(function() {129        StoryUpdateService.addDestinationNodeIdToNode(130          _sampleStory, 'node_1', 'node_5');131      }).toThrow();132      expect(133        _sampleStory.getStoryContents().getNodes()[0].getDestinationNodeIds()134      ).toEqual(['node_2']);135      UndoRedoService.undoChange(_sampleStory);136      expect(137        _sampleStory.getStoryContents().getNodes()[0].getDestinationNodeIds()138      ).toEqual([]);139    }140  );141  it('should create a proper backend change dict for adding a destination ' +142    'node id to a node',143  function() {144    StoryUpdateService.addDestinationNodeIdToNode(145      _sampleStory, 'node_1', 'node_2');146    expect(UndoRedoService.getCommittableChangeList()).toEqual([{147      cmd: 'update_story_node_property',148      property_name: 'destination_node_ids',149      new_value: ['node_2'],150      old_value: [],151      node_id: 'node_1'152    }]);153  });154  it('should remove/add a prerequisite skill id from/to a node in the story',155    function() {156      expect(157        _sampleStory.getStoryContents().getNodes()[0].getPrerequisiteSkillIds()158      ).toEqual(['skill_1']);159      StoryUpdateService.removePrerequisiteSkillIdFromNode(160        _sampleStory, 'node_1', 'skill_1');161      expect(162        _sampleStory.getStoryContents().getNodes()[0].getPrerequisiteSkillIds()163      ).toEqual([]);164      UndoRedoService.undoChange(_sampleStory);165      expect(166        _sampleStory.getStoryContents().getNodes()[0].getPrerequisiteSkillIds()167      ).toEqual(['skill_1']);168    }169  );170  it('should create a proper backend change dict for removing a prerequisite ' +171    'skill id from a node',172  function() {173    StoryUpdateService.removePrerequisiteSkillIdFromNode(174      _sampleStory, 'node_1', 'skill_1');175    expect(UndoRedoService.getCommittableChangeList()).toEqual([{176      cmd: 'update_story_node_property',177      property_name: 'prerequisite_skill_ids',178      new_value: [],179      old_value: ['skill_1'],180      node_id: 'node_1'181    }]);182  });183  it('should remove/add an acquired skill id from/to a node in the story',184    function() {185      expect(186        _sampleStory.getStoryContents().getNodes()[0].getAcquiredSkillIds()187      ).toEqual(['skill_2']);188      StoryUpdateService.removeAcquiredSkillIdFromNode(189        _sampleStory, 'node_1', 'skill_2');190      expect(191        _sampleStory.getStoryContents().getNodes()[0].getAcquiredSkillIds()192      ).toEqual([]);193      UndoRedoService.undoChange(_sampleStory);194      expect(195        _sampleStory.getStoryContents().getNodes()[0].getAcquiredSkillIds()196      ).toEqual(['skill_2']);197    }198  );199  it('should create a proper backend change dict for removing an acquired ' +200    'skill id from a node',201  function() {202    StoryUpdateService.removeAcquiredSkillIdFromNode(203      _sampleStory, 'node_1', 'skill_2');204    expect(UndoRedoService.getCommittableChangeList()).toEqual([{205      cmd: 'update_story_node_property',206      property_name: 'acquired_skill_ids',207      new_value: [],208      old_value: ['skill_2'],209      node_id: 'node_1'210    }]);211  });212  it('should remove/add a destination node id from/to a node in the story',213    function() {214      expect(215        _sampleStory.getStoryContents().getNodes()[1].getDestinationNodeIds()216      ).toEqual(['node_1']);217      StoryUpdateService.removeDestinationNodeIdFromNode(218        _sampleStory, 'node_2', 'node_1');219      expect(220        _sampleStory.getStoryContents().getNodes()[1].getDestinationNodeIds()221      ).toEqual([]);222      UndoRedoService.undoChange(_sampleStory);223      expect(224        _sampleStory.getStoryContents().getNodes()[1].getDestinationNodeIds()225      ).toEqual(['node_1']);226    }227  );228  it('should create a proper backend change dict for removing a destination ' +229    'node id from a node',230  function() {231    StoryUpdateService.removeDestinationNodeIdFromNode(232      _sampleStory, 'node_2', 'node_1');233    expect(UndoRedoService.getCommittableChangeList()).toEqual([{234      cmd: 'update_story_node_property',235      property_name: 'destination_node_ids',236      new_value: [],237      old_value: ['node_1'],238      node_id: 'node_2'239    }]);240  });241  it('should add/remove a story node', function() {242    expect(_sampleStory.getStoryContents().getNodes().length).toEqual(2);243    StoryUpdateService.addStoryNode(_sampleStory, 'Title 2');244    expect(_sampleStory.getStoryContents().getNodes().length).toEqual(3);245    expect(_sampleStory.getStoryContents().getNextNodeId()).toEqual('node_4');246    expect(247      _sampleStory.getStoryContents().getNodes()[2].getId()).toEqual('node_3');248    expect(249      _sampleStory.getStoryContents().getNodes()[2].getTitle()).toEqual(250      'Title 2');251    UndoRedoService.undoChange(_sampleStory);252    expect(_sampleStory.getStoryContents().getNodes().length).toEqual(2);253  });254  it('should create a proper backend change dict for adding a story node',255    function() {256      StoryUpdateService.addStoryNode(_sampleStory, 'Title 2');257      expect(UndoRedoService.getCommittableChangeList()).toEqual([{258        cmd: 'add_story_node',259        node_id: 'node_3',260        title: 'Title 2'261      }]);262    }263  );264  it('should remove/add a story node', function() {265    expect(function() {266      StoryUpdateService.deleteStoryNode(_sampleStory, 'node_2');267    }).toThrow();268    expect(_sampleStory.getStoryContents().getNodes().length).toEqual(2);269    expect(270      _sampleStory.getStoryContents().getNodes()[1].getDestinationNodeIds()271    ).toEqual(['node_1']);272    StoryUpdateService.deleteStoryNode(_sampleStory, 'node_1');273    // Initial node should not be deleted.274    StoryUpdateService.deleteStoryNode(_sampleStory, 'node_2');275    expect(_sampleStory.getStoryContents().getInitialNodeId()).toEqual(null);276    expect(_sampleStory.getStoryContents().getNodes().length).toEqual(0);277    expect(function() {278      UndoRedoService.undoChange(_sampleStory);279    }).toThrow();280  });281  it('should create a proper backend change dict for removing a story node',282    function() {283      StoryUpdateService.deleteStoryNode(_sampleStory, 'node_1');284      expect(UndoRedoService.getCommittableChangeList()).toEqual([{285        cmd: 'delete_story_node',286        node_id: 'node_1'287      }]);288    }289  );290  it('should finalize a story node outline', function() {291    expect(292      _sampleStory.getStoryContents().getNodes()[0].getOutlineStatus()293    ).toBe(false);294    StoryUpdateService.finalizeStoryNodeOutline(_sampleStory, 'node_1');295    expect(296      _sampleStory.getStoryContents().getNodes()[0].getOutlineStatus()297    ).toBe(true);298    UndoRedoService.undoChange(_sampleStory);299    expect(300      _sampleStory.getStoryContents().getNodes()[0].getOutlineStatus()301    ).toBe(false);302  });303  it('should create a proper backend change dict for finalizing a node outline',304    function() {305      StoryUpdateService.finalizeStoryNodeOutline(_sampleStory, 'node_1');306      expect(UndoRedoService.getCommittableChangeList()).toEqual([{307        cmd: 'update_story_node_outline_status',308        new_value: true,309        old_value: false,310        node_id: 'node_1'311      }]);312    }313  );314  it('should unfinalize a story node outline', function() {315    expect(316      _sampleStory.getStoryContents().getNodes()[1].getOutlineStatus()317    ).toBe(true);318    StoryUpdateService.unfinalizeStoryNodeOutline(_sampleStory, 'node_2');319    expect(320      _sampleStory.getStoryContents().getNodes()[1].getOutlineStatus()321    ).toBe(false);322    UndoRedoService.undoChange(_sampleStory);323    expect(324      _sampleStory.getStoryContents().getNodes()[1].getOutlineStatus()325    ).toBe(true);326  });327  it('should create a proper backend change dict for unfinalizing a node ' +328    'outline', function() {329    StoryUpdateService.unfinalizeStoryNodeOutline(_sampleStory, 'node_2');330    expect(UndoRedoService.getCommittableChangeList()).toEqual([{331      cmd: 'update_story_node_outline_status',332      new_value: false,333      old_value: true,334      node_id: 'node_2'335    }]);336  });337  it('should set a story node outline', function() {338    expect(339      _sampleStory.getStoryContents().getNodes()[0].getOutline()340    ).toBe('Outline');341    StoryUpdateService.setStoryNodeOutline(342      _sampleStory, 'node_1', 'new outline');343    expect(344      _sampleStory.getStoryContents().getNodes()[0].getOutline()345    ).toBe('new outline');346    UndoRedoService.undoChange(_sampleStory);347    expect(348      _sampleStory.getStoryContents().getNodes()[0].getOutline()349    ).toBe('Outline');350  });351  it('should create a proper backend change dict for setting a node outline',352    function() {353      StoryUpdateService.setStoryNodeOutline(354        _sampleStory, 'node_1', 'new outline');355      expect(UndoRedoService.getCommittableChangeList()).toEqual([{356        cmd: 'update_story_node_property',357        property_name: 'outline',358        new_value: 'new outline',359        old_value: 'Outline',360        node_id: 'node_1'361      }]);362    }363  );364  it('should set a story node title', function() {365    expect(366      _sampleStory.getStoryContents().getNodes()[0].getTitle()367    ).toBe('Title 1');368    StoryUpdateService.setStoryNodeTitle(369      _sampleStory, 'node_1', 'new title');370    expect(371      _sampleStory.getStoryContents().getNodes()[0].getTitle()372    ).toBe('new title');373    UndoRedoService.undoChange(_sampleStory);374    expect(375      _sampleStory.getStoryContents().getNodes()[0].getTitle()376    ).toBe('Title 1');377  });378  it('should create a proper backend change dict for setting a node title',379    function() {380      StoryUpdateService.setStoryNodeTitle(381        _sampleStory, 'node_1', 'new title');382      expect(UndoRedoService.getCommittableChangeList()).toEqual([{383        cmd: 'update_story_node_property',384        property_name: 'title',385        new_value: 'new title',386        old_value: 'Title 1',387        node_id: 'node_1'388      }]);389    }390  );391  it('should set the exploration id of a story node', function() {392    expect(393      _sampleStory.getStoryContents().getNodes()[0].getExplorationId()394    ).toBe(null);395    StoryUpdateService.setStoryNodeExplorationId(396      _sampleStory, 'node_1', 'exp_2');397    expect(398      _sampleStory.getStoryContents().getNodes()[0].getExplorationId()399    ).toBe('exp_2');400    // Adding an already existing exploration in the story should throw an401    // error.402    expect(function() {403      StoryUpdateService.setStoryNodeExplorationId(404        _sampleStory, 'node_1', 'exp_1');405    }).toThrow();406    UndoRedoService.undoChange(_sampleStory);407    expect(408      _sampleStory.getStoryContents().getNodes()[0].getExplorationId()409    ).toBe(null);410  });411  it('should create a proper backend change dict for setting the exploration ' +412    'id of a node', function() {413    StoryUpdateService.setStoryNodeExplorationId(414      _sampleStory, 'node_1', 'exp_2');415    expect(UndoRedoService.getCommittableChangeList()).toEqual([{416      cmd: 'update_story_node_property',417      property_name: 'exploration_id',418      new_value: 'exp_2',419      old_value: null,420      node_id: 'node_1'421    }]);422  });423  it('should set/unset the initial node of the story', function() {424    expect(425      _sampleStory.getStoryContents().getInitialNodeId()).toEqual('node_2');426    StoryUpdateService.setInitialNodeId(_sampleStory, 'node_1');427    expect(428      _sampleStory.getStoryContents().getInitialNodeId()).toEqual('node_1');429    UndoRedoService.undoChange(_sampleStory);430    expect(431      _sampleStory.getStoryContents().getInitialNodeId()).toEqual('node_2');432  });433  it('should create a proper backend change dict for setting initial node',434    function() {435      StoryUpdateService.setInitialNodeId(_sampleStory, 'node_1');436      expect(UndoRedoService.getCommittableChangeList()).toEqual([{437        cmd: 'update_story_contents_property',438        property_name: 'initial_node_id',439        new_value: 'node_1',440        old_value: 'node_2'441      }]);442    }443  );444  it('should set/unset changes to a story\'s title', function() {445    expect(_sampleStory.getTitle()).toEqual('Story title');...Using AI Code Generation
1import { getStoryContents } from 'storybook-root';2const story = getStoryContents('test-story');3console.log(story);4import { storiesOf } from '@storybook/react';5storiesOf('Test Story', module)6  .add('test', () => {7    const story = getStoryContents('test-story');8    console.log(story);9  });Using AI Code Generation
1import { getStoryContents } from 'storybook-root';2const story = getStoryContents('my-story');3import { getStoryContents } from 'storybook-root';4const story = getStoryContents('my-story');5import { getStoryContents } from 'storybook-root';6import cheerio from 'cheerio';7const story = getStoryContents('my-story');8const $ = cheerio.load(story);9import { getStoryContents } from 'storybook-root';10import cheerio from 'cheerio';11const story = getStoryContents('my-story');12const $ = cheerio.load(story);13import { getStoryContents } from 'storybook-root';14import cheerio from 'cheerio';15const story = getStoryContents('my-story');16const $ = cheerio.load(story);17import { getStoryContents } from 'storybook-root';18import cheerio from 'cheerio';19const story = getStoryContents('my-story');20const $ = cheerio.load(story);Using AI Code Generation
1import { getStoryContents } from 'storybook-root'2const storyContents = getStoryContents('my-story-name')3const storyContents = getStoryContents('my-story-name', 'my-story-kind')4const storyContents = getStoryContents('my-story-name', 'my-story-kind', 'my-story-component')5const storyContents = getStoryContents('my-story-name', 'my-story-kind', 'my-story-component', 'my-story-variant')6const storyContents = getStoryContents('my-story-name', 'my-story-kind', 'my-story-component', 'my-story-variant', 'my-story-state')7const storyContents = getStoryContents('my-story-name', 'my-story-kind', 'my-story-component', 'my-story-variant', 'my-story-state', 'my-story-variant-state')8const storyContents = getStoryContents('my-story-name', 'my-story-kind', 'my-story-component', 'my-story-variant', 'my-story-state', 'my-story-variant-state', 'my-story-variant-state-variant')9const storyContents = getStoryContents('my-story-name', 'my-story-kind', 'my-story-component', 'my-story-variant', 'my-story-state', 'my-story-variant-state', 'my-story-variant-state-variant', 'my-story-variant-state-variant-variant')10const storyContents = getStoryContents('my-story-name', 'my-story-kind', 'my-story-component', 'my-story-variant', 'my-story-state', 'my-story-variant-state', 'my-story-variant-state-variant', 'my-story-variant-state-variant-variant', 'my-story-variant-state-variant-variant-variant')11const storyContents = getStoryContents('my-story-name', 'myUsing AI Code Generation
1import { getStoryContents } from 'storybook-root';2const storyContents = getStoryContents('my-storybook-name');3import { getStoryContents } from 'storybook-root';4const storyContents = getStoryContents('my-storybook-name');5import { getStoryContents } from 'storybook-root';6const storyContents = getStoryContents('my-storybook-name');7import { getStoryContents } from 'storybook-root';8const storyContents = getStoryContents('my-storybook-name');9import { getStoryContents } from 'storybook-root';10const storyContents = getStoryContents('my-storybook-name');11import { getStoryContents } from 'storybook-root';12const storyContents = getStoryContents('my-storybook-name');13import { getStoryContents } from 'storybook-root';14const storyContents = getStoryContents('my-storybook-name');15import { getStoryContents } from 'storybook-root';16const storyContents = getStoryContents('my-storybook-name');17import { getStoryContents } from 'storybook-root';18const storyContents = getStoryContents('my-storybook-name');Using AI Code Generation
1const storybookRoot = require('storybook-root')2const storyContents = storybookRoot.getStoryContents(storybookPath, storyName)3console.log(storyContents)4const storybookRoot = require('storybook-root')5const storyContents = storybookRoot.getStoryContents(storybookPath, storyName)6console.log(storyContents)7const storybookRoot = require('storybook-root')8const storyContents = storybookRoot.getStoryContents(storybookPath, storyName)9console.log(storyContents)10const storybookRoot = require('storybook-root')11const storyContents = storybookRoot.getStoryContents(storybookPath, storyName)12console.log(storyContents)13const storybookRoot = require('storybook-root')14const storyContents = storybookRoot.getStoryContents(storybookPath, storyName)15console.log(storyContents)16const storybookRoot = require('storybook-root')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!!
