{"size": 1330, "ext": "js", "max_stars_repo_path": "app/tests/models/tag.server.model.test.js", "max_stars_repo_name": "apbetioli/xegg-server", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/tests/models/tag.server.model.test.js", "max_issues_repo_name": "apbetioli/xegg-server", "max_issues_repo_issues_event_min_datetime": "2020-07-18T11:38:49.000Z", "max_issues_repo_issues_event_max_datetime": "2020-07-29T17:16:22.000Z", "max_forks_repo_path": "app/tests/models/tag.server.model.test.js", "max_forks_repo_name": "apbetioli/xegg-server", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 23.75, "max_line_length": 95, "alphanum_fraction": 0.4601503759}
'use strict';

var should = require('should'),
    mongoose = require('mongoose'),
    Tag = mongoose.model('Tag');

var tag, tag2;

describe('Tag Model Unit Tests:', function () {
    beforeEach(function (done) {
        tag = new Tag({
            tag: 'automodelismo'
        });

        tag2 = new Tag({
            tag: 'automodelismo'
        });

        done();
    });

    describe('Method Save', function () {
        it('should be able to save without problems', function (done) {
            return tag.save(function (err) {
                should.not.exist(err);
                should.exist(tag.created);
                done();
            });
        });

        it('should be able to show an error when try to save without name', function (done) {
            tag.tag = '';

            return tag.save(function (err) {
                should.exist(err);
                done();
            });
        });
        /*
        TODO ver pq não passa

        it('should be able to show an error when try to save two equal tags', function (done) {
            tag.save();
            return tag2.save(function (err) {
                should.exist(err);
                done();
            });
        });
        */
    });

    afterEach(function (done) {
        Tag.remove().exec();
        done();
    });
});