/**
 * sso类单元测试
 *
 * @author CaiAoLin
 * @date 2017/11/17
 * @version
 */

'use strict';

const { app, assert } = require('egg-mock/bootstrap');
const SSO = require('../../../app/lib/sso');

describe('test/app/lib/sso.test.js', () => {

    it('login success valid', function* () {
        const ctx = app.mockContext();
        const sso = new SSO(ctx);

        const username = 'laiku123@qq.com';
        const password = '19930523';
        const result = yield sso.loginValid(username, password);

        // 验证返回
        assert(result);

        // 验证数据库中是否新增了账号
        const customer = yield ctx.service.customer.getDataByCondition({ email: username });
        assert(customer !== null);
    });

});
