File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
tests/unit/controllers/crate Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ import { module , test } from 'qunit' ;
2+ import { setupTest } from 'ember-qunit' ;
3+ import { A } from '@ember/array' ;
4+ import Service from '@ember/service' ;
5+
6+ module ( 'Unit | Controller | crate/version' , function ( hooks ) {
7+ setupTest ( hooks ) ;
8+ const userId = 1 ;
9+ // stub the session service
10+ // https://guides.emberjs.com/release/testing/testing-components/#toc_stubbing-services
11+ const sessionStub = Service . extend ( ) ;
12+
13+ hooks . beforeEach ( function ( ) {
14+ sessionStub . currentUser = { id : userId } ;
15+ this . owner . register ( 'service:session' , sessionStub ) ;
16+ } ) ;
17+
18+ test ( 'notYankedOrIsOwner is true when conditions fulfilled' , function ( assert ) {
19+ assert . expect ( 2 ) ;
20+ let controller = this . owner . lookup ( 'controller:crate/version' ) ;
21+ controller . model = { yanked : false } ;
22+ controller . crate = { owner_user : A ( [ { id : userId } ] ) } ;
23+ assert . ok ( controller ) ;
24+ assert . ok ( controller . notYankedOrIsOwner ) ;
25+ } ) ;
26+
27+ test ( 'notYankedOrIsOwner is false when conditions fulfilled' , function ( assert ) {
28+ assert . expect ( 2 ) ;
29+ let controller = this . owner . lookup ( 'controller:crate/version' ) ;
30+ controller . model = { yanked : true } ;
31+ controller . crate = { owner_user : A ( [ { id : userId } ] ) } ;
32+ assert . ok ( controller ) ;
33+ assert . notOk ( controller . notYankedOrIsOwner ) ;
34+ } ) ;
35+ } ) ;
You can’t perform that action at this time.
0 commit comments