"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var chai_1 = require("chai");
var getSuggestion_1 = require("../../../src/core/utils/getSuggestion");
var commons_1 = require("@universal-login/commons");
describe('getSuggestion', function () {
    it('Creation', function () {
        chai_1.expect(getSuggestion_1.getSuggestion({ creations: ['user.mylogin.eth'], connections: [] }, commons_1.WALLET_SUGGESTION_ALL_ACTIONS, 'user'))
            .be.deep.eq({ kind: 'Creation', name: 'user.mylogin.eth' });
        chai_1.expect(getSuggestion_1.getSuggestion({ creations: ['user.mylogin.eth'], connections: ['user.mylogin2.eth'] }, [commons_1.WalletSuggestionAction.create], 'user'))
            .be.deep.eq({ kind: 'Creation', name: 'user.mylogin.eth' });
        chai_1.expect(getSuggestion_1.getSuggestion({ creations: ['user.mylogin.eth'], connections: [] }, [commons_1.WalletSuggestionAction.create], 'user'))
            .be.deep.eq({ kind: 'Creation', name: 'user.mylogin.eth' });
    });
    it('Connection', function () {
        chai_1.expect(getSuggestion_1.getSuggestion({ creations: [], connections: ['user.mylogin.eth'] }, commons_1.WALLET_SUGGESTION_ALL_ACTIONS, 'user'))
            .be.deep.eq({ kind: 'Connection', name: 'user.mylogin.eth' });
        chai_1.expect(getSuggestion_1.getSuggestion({ creations: ['user.mylogin2.eth'], connections: ['user.mylogin.eth'] }, [commons_1.WalletSuggestionAction.connect], 'user'))
            .be.deep.eq({ kind: 'Connection', name: 'user.mylogin.eth' });
        chai_1.expect(getSuggestion_1.getSuggestion({ creations: [], connections: ['user.mylogin.eth'] }, [commons_1.WalletSuggestionAction.connect], 'user'))
            .be.deep.eq({ kind: 'Connection', name: 'user.mylogin.eth' });
    });
    describe('Available', function () {
        it('2 creations, no connections', function () {
            chai_1.expect(getSuggestion_1.getSuggestion({ creations: ['user.mylogin.eth', 'user.mylogin2.eth'], connections: [] }, commons_1.WALLET_SUGGESTION_ALL_ACTIONS, 'user'))
                .be.deep.eq({ kind: 'Available', suggestions: [{ kind: 'Creation', name: 'user.mylogin.eth' }, { kind: 'Creation', name: 'user.mylogin2.eth' }] });
        });
        it('no creations, 2 connections', function () {
            chai_1.expect(getSuggestion_1.getSuggestion({ creations: [], connections: ['user.mylogin.eth', 'user.mylogin2.eth'] }, commons_1.WALLET_SUGGESTION_ALL_ACTIONS, 'user'))
                .be.deep.eq({ kind: 'Available', suggestions: [{ kind: 'Connection', name: 'user.mylogin.eth' }, { kind: 'Connection', name: 'user.mylogin2.eth' }] });
        });
        it('Connection and creation', function () {
            chai_1.expect(getSuggestion_1.getSuggestion({ creations: ['user.mylogin.eth'], connections: ['user.mylogin2.eth'] }, commons_1.WALLET_SUGGESTION_ALL_ACTIONS, 'user'))
                .be.deep.eq({ kind: 'Available', suggestions: [{ kind: 'Creation', name: 'user.mylogin.eth' }, { kind: 'Connection', name: 'user.mylogin2.eth' }] });
        });
    });
    describe('TakenOrInvalid', function () {
        it('empty connections, empty creations, create action', function () {
            chai_1.expect(getSuggestion_1.getSuggestion({ creations: [], connections: [] }, [commons_1.WalletSuggestionAction.create], 'user'))
                .be.deep.eq({ kind: 'TakenOrInvalid' });
        });
        it('non-empty connections, empty creations, create action', function () {
            chai_1.expect(getSuggestion_1.getSuggestion({ creations: [], connections: ['user.mylogin.eth'] }, [commons_1.WalletSuggestionAction.create], 'user'))
                .be.deep.eq({ kind: 'TakenOrInvalid' });
        });
    });
    describe('isInvalidForConnection', function () {
        it('empty connections, empty creations, invalid name', function () {
            chai_1.expect(getSuggestion_1.getSuggestion({ creations: [], connections: [] }, [commons_1.WalletSuggestionAction.connect], 'user'))
                .be.deep.eq({ kind: 'InvalidForConnection' });
        });
        it('non-empty connections, empty creations, invalid name', function () {
            chai_1.expect(getSuggestion_1.getSuggestion({ creations: ['user.mylogin.eth'], connections: [] }, [commons_1.WalletSuggestionAction.connect], 'user'))
                .be.deep.eq({ kind: 'InvalidForConnection' });
        });
    });
    describe('KeepTyping', function () {
        var shortEnsName = 'us';
        it('empty connections, empty creations', function () {
            chai_1.expect(getSuggestion_1.getSuggestion({ creations: [], connections: [] }, commons_1.WALLET_SUGGESTION_ALL_ACTIONS, shortEnsName))
                .be.deep.eq({ kind: 'KeepTyping' });
        });
        it('non-empty connections, empty creations', function () {
            chai_1.expect(getSuggestion_1.getSuggestion({ creations: [], connections: ['us.mylogin.eth'] }, commons_1.WALLET_SUGGESTION_ALL_ACTIONS, shortEnsName))
                .be.deep.eq({ kind: 'KeepTyping' });
        });
        it('empty connections, non-empty creations', function () {
            chai_1.expect(getSuggestion_1.getSuggestion({ creations: ['us.mylogin.eth'], connections: [] }, commons_1.WALLET_SUGGESTION_ALL_ACTIONS, shortEnsName))
                .be.deep.eq({ kind: 'KeepTyping' });
        });
    });
    describe('None', function () {
        var emptyEnsName = '';
        it('empty connections, empty creations', function () {
            chai_1.expect(getSuggestion_1.getSuggestion({ creations: [], connections: [] }, commons_1.WALLET_SUGGESTION_ALL_ACTIONS, emptyEnsName))
                .be.deep.eq({ kind: 'None' });
        });
        it('non-empty connections, empty creations', function () {
            chai_1.expect(getSuggestion_1.getSuggestion({ creations: [], connections: ['.mylogin.eth'] }, commons_1.WALLET_SUGGESTION_ALL_ACTIONS, emptyEnsName))
                .be.deep.eq({ kind: 'None' });
        });
        it('empty connections, non-empty creations', function () {
            chai_1.expect(getSuggestion_1.getSuggestion({ creations: ['.mylogin.eth'], connections: [] }, commons_1.WALLET_SUGGESTION_ALL_ACTIONS, emptyEnsName))
                .be.deep.eq({ kind: 'None' });
            chai_1.expect(getSuggestion_1.getSuggestion({ creations: ['.mylogin.eth'], connections: [] }, [commons_1.WalletSuggestionAction.create], emptyEnsName))
                .be.deep.eq({ kind: 'None' });
            chai_1.expect(getSuggestion_1.getSuggestion({ creations: ['.mylogin.eth'], connections: [] }, [commons_1.WalletSuggestionAction.connect], emptyEnsName))
                .be.deep.eq({ kind: 'None' });
        });
        it('empty connections, empty creations', function () {
            chai_1.expect(getSuggestion_1.getSuggestion({ creations: [], connections: [] }, commons_1.WALLET_SUGGESTION_ALL_ACTIONS, 'user'))
                .be.deep.eq({ kind: 'None' });
        });
        it('single creation without creation action', function () {
            chai_1.expect(getSuggestion_1.getSuggestion({ creations: ['user.mylogin.eth'], connections: [] }, [], 'user'))
                .be.deep.eq({ kind: 'None' });
        });
        it('single connection with empty action', function () {
            chai_1.expect(getSuggestion_1.getSuggestion({ creations: [], connections: ['user.mylogin.eth'] }, [], 'user'))
                .be.deep.eq({ kind: 'None' });
        });
    });
});
//# sourceMappingURL=getSuggestion.test.js.map