<commit_before>import { DatePipe } from '@angular/common';
import { fakeAsync, TestBed } from '@angular/core/testing';
import { fastTestSetup } from '../../../../test/helpers';
import { FsMatchLiterals, MockFsService } from '../../../../test/mocks/browser';
import { FsService } from '../../shared';
import { basicFixture } from '../fixtures';
import { NoteParser } from '../note-shared';
import { NoteEditorService } from './note-editor.service';


describe('browser.note.noteEditor.NoteEditorService', () => {
    let noteEditor: NoteEditorService;
    let mockFs: MockFsService;

    fastTestSetup();

    beforeAll(() => {
        TestBed
            .configureTestingModule({
                imports: [],
                providers: [
                    DatePipe,
                    NoteParser,
                    ...MockFsService.providers(),
                    NoteEditorService,
                ],
            });
    });

    beforeEach(() => {
        noteEditor = TestBed.get(NoteEditorService);
        mockFs = TestBed.get(FsService);
    });

    afterEach(() => {
        mockFs.verify();
    });

    describe('loadNoteContent', () => {
        it('should load files and parse to note content.', fakeAsync(() => {
            const callback = jasmine.createSpy('load note content callback');
            const subscription = noteEditor.loadNoteContent(basicFixture.noteItem).subscribe(callback);

            const stubs = mockFs.expectMany([
                {
                    methodName: 'readJsonFile',
                    args: [basicFixture.noteItem.filePath],
                },
                {
                    methodName: 'readFile',
                    args: [basicFixture.noteItem.contentFilePath],
                },
            ]);

            stubs[0].flush(basicFixture.note);
            stubs[1].flush(basicFixture.contentRawValue);

            expect(callback).toHaveBeenCalledWith(basicFixture.content);
            subscription.unsubscribe();
        }));
    });

    describe('saveNote', () => {
        it('should write note and content file.', fakeAsync(() => {
            const callback = jasmine.createSpy('save note callback');
            const subscription = noteEditor.saveNote(
                basicFixture.noteItem,
                basicFixture.content,
            ).subscribe(callback);

            const stubs = mockFs.expectMany([
                {
                    methodName: 'writeJsonFile',
                    args: [basicFixture.noteItem.filePath, FsMatchLiterals.ANY],
                },
                {
                    methodName: 'writeFile',
                    args: [
                        basicFixture.note.contentFilePath,
                        basicFixture.contentParsedValue,
                    ],
                },
            ]);

            stubs[0].flush();
            stubs[1].flush();

            expect(callback).toHaveBeenCalled();
            subscription.unsubscribe();
        }));
    });
});<commit_msg>Fix test failure caused by mismatch of to be stored data<commit_after>import { DatePipe } from '@angular/common';
import { fakeAsync, TestBed } from '@angular/core/testing';
import { fastTestSetup } from '../../../../test/helpers';
import { FsMatchLiterals, MockFsService } from '../../../../test/mocks/browser';
import { FsService } from '../../shared';
import { basicFixture } from '../fixtures';
import { NoteParser } from '../note-shared';
import { NoteEditorService } from './note-editor.service';


describe('browser.note.noteEditor.NoteEditorService', () => {
    let noteEditor: NoteEditorService;
    let mockFs: MockFsService;

    fastTestSetup();

    beforeAll(() => {
        TestBed
            .configureTestingModule({
                imports: [],
                providers: [
                    DatePipe,
                    NoteParser,
                    ...MockFsService.providers(),
                    NoteEditorService,
                ],
            });
    });

    beforeEach(() => {
        noteEditor = TestBed.get(NoteEditorService);
        mockFs = TestBed.get(FsService);
    });

    afterEach(() => {
        mockFs.verify();
    });

    describe('loadNoteContent', () => {
        it('should load files and parse to note content.', fakeAsync(() => {
            const callback = jasmine.createSpy('load note content callback');
            const subscription = noteEditor.loadNoteContent(basicFixture.noteItem).subscribe(callback);

            const stubs = mockFs.expectMany([
                {
                    methodName: 'readJsonFile',
                    args: [basicFixture.noteItem.filePath],
                },
                {
                    methodName: 'readFile',
                    args: [basicFixture.noteItem.contentFilePath],
                },
            ]);

            stubs[0].flush(basicFixture.note);
            stubs[1].flush(basicFixture.contentRawValue);

            expect(callback).toHaveBeenCalledWith(basicFixture.content);
            subscription.unsubscribe();
        }));
    });

    describe('saveNote', () => {
        it('should write note and content file.', fakeAsync(() => {
            const callback = jasmine.createSpy('save note callback');
            const subscription = noteEditor.saveNote(
                basicFixture.noteItem,
                basicFixture.content,
            ).subscribe(callback);

            mockFs
                .expectMany([
                    {
                        methodName: 'writeJsonFile',
                        args: [basicFixture.noteItem.filePath, FsMatchLiterals.ANY],
                    },
                    {
                        methodName: 'writeFile',
                        args: [
                            basicFixture.note.contentFilePath,
                            FsMatchLiterals.ANY,
                        ],
                    },
                ])
                .forEach(stub => stub.flush());

            expect(callback).toHaveBeenCalled();
            subscription.unsubscribe();
        }));
    });
});
{'fraction_non_alphanumeric': 0.12639344262295082, 'fraction_numerical': 0.0009836065573770492, 'mean_word_length': 1.5580712788259958, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, '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': '5214015', 'n_tokens_mistral': 1550, 'n_tokens_neox': 1454, 'n_words': 265}