Skip to content

Commit

Permalink
tests: named model
Browse files Browse the repository at this point in the history
  • Loading branch information
farwayer committed Sep 2, 2019
1 parent 788c79c commit 02c6a66
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export declare interface Model<T extends Function> {
}

export declare function model<T extends Function>(target: T): T & Model<T> & PropertyDecorator
export declare function model(name: string): typeof model
export declare function prop(...args: any[]): any
export declare const view: MethodDecorator

Expand Down
10 changes: 10 additions & 0 deletions test/js/basic.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {getMembers} from 'mobx-state-tree'
import {model, prop, view, types as t} from '../../src'
import {timeout} from '../utils'

Expand Down Expand Up @@ -100,6 +101,15 @@ describe('basic', () => {
base.should.have.property('late').which.is.equal('late')
})

it('named model', () => {
@model('User') class Base {
@t.str str = '123'
}

const base = Base.create()
getMembers(base).name.should.be.equal('User')
})

it('prop', () => {
@model class Base {
@prop(t.str) prop
Expand Down
8 changes: 8 additions & 0 deletions test/ts/basic.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {getMembers} from 'mobx-state-tree'
import {model, prop, view, types as t} from '../../src'
import {timeout} from '../utils'

Expand Down Expand Up @@ -105,6 +106,13 @@ describe('basic', () => {
base.should.have.property('late').which.is.equal('late')
})

it('named model', () => {
const Base = model('User')(class {})

const base = Base.create()
getMembers(base).name.should.be.equal('User')
})

it('prop', () => {
class MBase {
@prop(t.str) prop
Expand Down

0 comments on commit 02c6a66

Please sign in to comment.