<commit_before>"use strict";

const TreeView = require("./utils/tree-view.js");
const Options = require("../lib/options.js");


describe("Tree-view", () => {
	const {assertIconClasses, resetOptions, setTheme} = require("./utils");
	
	before(() => {
		resetOptions();
		const [treeView] = atom.workspace.getLeftDock().getPaneItems();
		expect(treeView).to.exist.and.equal(TreeView.view);
		TreeView.refresh();
	});
	
	afterEach(() => {
		TreeView.refresh();
		TreeView.select(null);
	});
	
	const allColouredFiles = [
		["subfolder/almighty.c",  "medium-blue"],
		["subfolder/fad.jsx",     "medium-blue"],
		["subfolder/markup.html", "medium-orange"],
		["subfolder/script.js",   "medium-yellow"],
		[".gitignore",            "medium-red"],
		["data.json",             "medium-cyan"],
		["image.gif",             "medium-yellow"],
		["markdown.md",           "medium-blue"],
		["package.json",          "medium-red"],
		["README.md",             "medium-blue"],
		["text.txt",              "medium-blue"],
	];
	
	
	when("a file entry is displayed", () => {
		when("it matches an icon", () => {
			it("shows the icon next to its name", () => {
				assertIconClasses(TreeView.entries, [
					[".default-config", "name icon"],
					[".default-gear",   "gear-icon"],
					[".gitignore",      "git-icon"],
					["data.json",       "json-icon"],
					["image.gif",       "image-icon"],
					["markdown.md",     "markdown-icon"],
					["package.json",    "npm-icon"],
					["README.md",       "book-icon"],
					["text.txt",        "icon-file-text"],
				]);
				
				TreeView.expand("subfolder");
				TreeView.refresh();
				assertIconClasses(TreeView.entries, [
					["subfolder/almighty.c",  "name icon c-icon"],
					["subfolder/fad.jsx",     "jsx-icon"],
					["subfolder/markup.html", "html5-icon"],
					["subfolder/script.js",   "js-icon"],
				]);
			});
			
			it("removes the built-in icon class", () => {
				assertIconClasses(TreeView.entries, [
					[".default-config", "icon-file-text"],
					["data.json",       "icon-file-text"],
					["la.tex",          "icon-file-text"],
					["markdown.md",     "icon-file-text"],
				], {negate: true});
			});
			
			when("coloured icons are enabled", () =>
				it("shows a coloured icon", () => {
					TreeView.refresh();
					assertIconClasses(TreeView.entries, [
						[".gitignore",   "medium-red"],
						["data.json",    "medium-cyan"],
						["image.gif",    "medium-yellow"],
						["markdown.md",  "medium-blue"],
						["package.json", "medium-red"],
						["README.md",    "medium-blue"],
						["text.txt",     "medium-blue"],
					]);
				}));
			
			when("coloured icons are disabled", () =>
				it("shows an uncoloured icon", () => {
					Options.set("coloured", false);
					assertIconClasses(TreeView.entries, [
						...allColouredFiles,
						["la.tex",   "medium-blue dark-blue"],
						[".bowerrc", "medium-orange medium-yellow"],
					], {negate: true});
				}));
			
			when("coloured icons are enabled later", () =>
				it("shows all existing icons in colour", () => {
					Options.set("coloured", true);
					assertIconClasses(TreeView.entries, [
						...allColouredFiles,
						["la.tex",   "medium-blue"],
						[".bowerrc", "medium-yellow"],
					]);
				}));
			
			when("in a Git repository", () => {
				it("shows the default repo-icon for the root directory", () =>
					TreeView.entries["."].className.should.equal("name icon icon-repo"));
				
				when('the "Only colour when changed" setting is enabled', () => {
					describe("If the file is unmodified", () =><commit_msg>Fix test failure in Atom v1.53-beta<commit_after>"use strict";

const TreeView = require("./utils/tree-view.js");
const Options = require("../lib/options.js");


describe("Tree-view", () => {
	const {assertIconClasses, resetOptions, setTheme} = require("./utils");
	
	before(() => {
		resetOptions();
		const [treeView] = atom.workspace.getLeftDock().getPaneItems();
		expect(treeView).to.exist.and.equal(TreeView.view);
		TreeView.refresh();
	});
	
	afterEach(() => {
		TreeView.refresh();
		TreeView.select(null);
	});
	
	const allColouredFiles = [
		["subfolder/almighty.c",  "medium-blue"],
		["subfolder/fad.jsx",     "medium-blue"],
		["subfolder/markup.html", "medium-orange"],
		["subfolder/script.js",   "medium-yellow"],
		[".gitignore",            "medium-red"],
		["data.json",             "medium-cyan"],
		["image.gif",             "medium-yellow"],
		["markdown.md",           "medium-blue"],
		["package.json",          "medium-red"],
		["README.md",             "medium-blue"],
		["text.txt",              "medium-blue"],
	];
	
	
	when("a file entry is displayed", () => {
		when("it matches an icon", () => {
			it("shows the icon next to its name", () => {
				assertIconClasses(TreeView.entries, [
					[".default-config", "name icon"],
					[".default-gear",   "gear-icon"],
					[".gitignore",      "git-icon"],
					["data.json",       "json-icon"],
					["image.gif",       "image-icon"],
					["markdown.md",     "markdown-icon"],
					["package.json",    "npm-icon"],
					["README.md",       "book-icon"],
					["text.txt",        "icon-file-text"],
				]);
				
				TreeView.expand("subfolder");
				TreeView.refresh();
				assertIconClasses(TreeView.entries, [
					["subfolder/almighty.c",  "name icon c-icon"],
					["subfolder/fad.jsx",     "jsx-icon"],
					["subfolder/markup.html", "html5-icon"],
					["subfolder/script.js",   "js-icon"],
				]);
			});
			
			it("removes the built-in icon class", () => {
				assertIconClasses(TreeView.entries, [
					[".default-config", "icon-file-text"],
					["data.json",       "icon-file-text"],
					["la.tex",          "icon-file-text"],
					["markdown.md",     "icon-file-text"],
				], {negate: true});
			});
			
			when("coloured icons are enabled", () =>
				it("shows a coloured icon", () => {
					TreeView.refresh();
					assertIconClasses(TreeView.entries, [
						[".gitignore",   "medium-red"],
						["data.json",    "medium-cyan"],
						["image.gif",    "medium-yellow"],
						["markdown.md",  "medium-blue"],
						["package.json", "medium-red"],
						["README.md",    "medium-blue"],
						["text.txt",     "medium-blue"],
					]);
				}));
			
			when("coloured icons are disabled", () =>
				it("shows an uncoloured icon", () => {
					Options.set("coloured", false);
					assertIconClasses(TreeView.entries, [
						...allColouredFiles,
						["la.tex",   "medium-blue dark-blue"],
						[".bowerrc", "medium-orange medium-yellow"],
					], {negate: true});
				}));
			
			when("coloured icons are enabled later", () =>
				it("shows all existing icons in colour", () => {
					Options.set("coloured", true);
					assertIconClasses(TreeView.entries, [
						...allColouredFiles,
						["la.tex",   "medium-blue"],
						[".bowerrc", "medium-yellow"],
					]);
				}));
			
			when("in a Git repository", () => {
				it("shows the default repo-icon for the root directory", () => {
					const classes = TreeView.entries["."].className.trim().split(/\s+/).sort();
					classes.should.eql(["icon", "icon-repo", "name"]);
				});
				
				when('the "Only colour when changed" setting is enabled', () => {
					describe("If the file is unmodified", () =>
{'fraction_non_alphanumeric': 0.21476137624861266, 'fraction_numerical': 0.0006936736958934517, 'mean_word_length': 2.620793571069814, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 37, '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': '3268585', 'n_tokens_mistral': 2971, 'n_tokens_neox': 2329, 'n_words': 416}