Guest User

Untitled

a guest
Apr 18th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ctid = ready = null
  2.  
  3. addChecklistTemplate = (title) ->
  4.   ct = new ca.model.ChecklistTemplateSchema.Schema()
  5.   ct.title = title
  6.   persistence.add ct
  7.   ct.id
  8.  
  9. addChecklistStepTemplate = (templateID, index, title) ->
  10.   cst = new ca.model.ChecklistStepTemplateSchema.Schema()
  11.   cst.checklistTemplate = templateID
  12.   cst.index = index
  13.   cst.text = title
  14.   persistence.add cst
  15.  
  16. beforeEach ->
  17.   persistence.debug = false
  18.   ca.model.Database.getInstance().init()
  19.   ca.model.ChecklistTemplateSchema.Schema.all().destroyAll ->
  20.     ca.model.ChecklistStepTemplateSchema.Schema.all().destroyAll ->
  21.       ctid = addChecklistTemplate 'Checklist Template 1'
  22.       addChecklistStepTemplate ctid, 1, 'Step 1'
  23.       persistence.flush ->
  24.         ready = true
  25.  
  26. describe 'Checklist Template Table', ->
  27.  
  28.   table = null
  29.   item = null
  30.   value = null
  31.  
  32.   beforeEach ->
  33.     waitsFor -> ready
  34.     table = ca.model.ChecklistTemplateTable
  35.     item = new table()
  36.  
  37.   afterEach ->
  38.     table = item = value = null
  39.  
  40.   it 'should return a list of checklist templates', ->
  41.     item.addEventListener table.EventType.LIST_LOADED, (event) -> value = event.value, false, this
  42.     item.getChecklistTemplates()
  43.  
  44.     waitsFor -> value
  45.  
  46.     runs ->
  47.       console.log value
  48.       expect( value ).not.toBe null
  49.       expect( value.length ).toBe 3
  50.  
  51.   it 'should return a checklist template by id', ->
  52.     item.addEventListener table.EventType.ITEM_LOADED, (event) -> value = event.value, false, this
  53.     item.getChecklistTemplate( ctid )
  54.  
  55.     waitsFor -> value
  56.  
  57.     runs ->
  58.       console.log value
  59.       expect( value ).not.toBe null
  60.       expect( value instanceof ca.model.ChecklistTemplate ).toBe true
Add Comment
Please, Sign In to add comment