<commit_before>import expect from 'expect';
import React from 'react';
import dva from '../src/index';
import dvaM from '../src/mobile';

describe('app.model', () => {

  it('namespace: type error', () => {
    const app = dva();
    expect(_ => {
      app.model({});
    }).toThrow(/app.model: namespace should be defined/);
    expect(_ => {
      app.model({
        namespace: 'routing',
      });
    }).toThrow(/app.model: namespace should not be routing/);

    const appM = dvaM();
    expect(_ => {
      appM.model({
        namespace: 'routing',
      });
    }).toNotThrow();
  });

  it('namespace: unique error', () => {
    const app = dva();
     expect(_ => {
      app.model({
        namespace: 'repeat'
      });
      app.model({
        namespace: 'repeat'
      });
    }).toThrow(/app.model: namespace should be unique/);

  });

  it('dynamic model', () => {
    let count = 0;

    const app = dva();
    app.model({
      namespace: 'users',
      state: [],
      reducers: {
        'add'(state, { payload }) {
          return [...state, payload];
        },
      },
    });
    app.router(_ => <div />);
    app.start();

    // inject model<commit_msg>delete space line<commit_after>import expect from 'expect';
import React from 'react';
import dva from '../src/index';
import dvaM from '../src/mobile';

describe('app.model', () => {

  it('namespace: type error', () => {
    const app = dva();
    expect(_ => {
      app.model({});
    }).toThrow(/app.model: namespace should be defined/);
    expect(_ => {
      app.model({
        namespace: 'routing',
      });
    }).toThrow(/app.model: namespace should not be routing/);

    const appM = dvaM();
    expect(_ => {
      appM.model({
        namespace: 'routing',
      });
    }).toNotThrow();
  });

  it('namespace: unique error', () => {
    const app = dva();
     expect(_ => {
      app.model({
        namespace: 'repeat'
      });
      app.model({
        namespace: 'repeat'
      });
    }).toThrow(/app.model: namespace should be unique/);
  });

  it('dynamic model', () => {
    let count = 0;

    const app = dva();
    app.model({
      namespace: 'users',
      state: [],
      reducers: {
        'add'(state, { payload }) {
          return [...state, payload];
        },
      },
    });
    app.router(_ => <div />);
    app.start();

    // inject model
{'fraction_non_alphanumeric': 0.19536842105263158, 'fraction_numerical': 0.0008421052631578948, 'mean_word_length': 2.015228426395939, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5359098', 'n_tokens_mistral': 742, 'n_tokens_neox': 728, 'n_words': 179}